{include file="user.header.html"}
<style>
.txt { margin-right:20px}
.spec ul { width: 630px; overflow: hidden; }
.spec .td { padding-bottom: 10px; }
.spec li { float: left; margin-left: 6px; display: inline; }
.spec li input { text-align: center; }
.spec .th { padding: 3px 0; margin-bottom: 10px; background: #f8f8f8; }
</style>
<div id="main" class="clearfix"> {include file="user.menu.html"}
  <div id="right"> {include file="user.curlocal.html"}
    <div class="wrapful">{include file="user.submenu.html"}
      <div id="seller_limitbuy_form" class="wrap">
        <div class="public">
          <div class="promotool">
            <div class="bundle bundle-list"> 
              <!--{if $appAvailable neq 'true'}-->
              <div class="notice-word">
                <p>{$appAvailable.msg}</p>
              </div>
              <!--{else}-->
              <div class="notice-word">
                <p class="yellow-big">{$lang.note_for_create}</p>
              </div>
              <form method="post" id="pro_form" enctype="multipart/form-data">
                <div class="information_index">
                  <h4>{$lang.limitbuy_basic_info}</h4>
                  <div class="add_wrap">
                    <div class="assort">
                      <p class="txt">{$lang.limitbuy_name}:</p>
                      <p>
                        <input type="text" name="pro_name" value="{$limitbuy.pro_name|escape}" class="text" />
                        <span class="red">*</span></p>
                    </div>
                    <div class="assort">
                      <p class="txt">{$lang.pro_image}:</p>
                      <p>
                        <input type="file" name="image" /><input type="hidden" name="fileVal" value="image" />
                        <span class="red">*</span>{$lang.pro_image_note}</p>
                      <!--{if $limitbuy.image}-->
                      <p><img src="{$limitbuy.image|url_format}" height="30" /></p>
                      <!--{/if}--> 
                    </div>
                    <div class="assort">
                      <p class="txt" > {$lang.start_time}:</p>
                      <p>
                        <input name="start_time" id="start_time" value='{$limitbuy.start_time|default:$now|date_format:"%Y-%m-%d %H:%M:%S"}' type="text" class="text" />
                        <span class="red">*</span> </p>
                    </div>
                    <div class="assort">
                      <p class="txt"> {$lang.end_time}:</p>
                      <p>
                        <input name="end_time" id="end_time" value='{$limitbuy.end_time|default:$now|date_format:"%Y-%m-%d %H:%M:%S"}' type="text" class="text" />
                        <span class="red">*</span> </p>
                    </div>
                    <div class="assort">
                      <p class="txt"> {$lang.pro_desc}:</p>
                      <p>
                        <textarea style="overflow-y: auto; width: 250px; vertical-align: top;" id="pro_desc" name="pro_desc" class="text">{$limitbuy.pro_desc|escape}</textarea>
                      </p>
                    </div>
                  </div>
                  <div class="add_wrap">
                    <div class="assort">
                      <p class="txt">{$lang.select_goods}:</p>
                      <p class="lst-products" style="width:630px;"> <a href="javascript:;" gs_id="seller_limitbuy" gs_name="goods_name" gs_callback="gs_callback1" gs_title="{$lang.gselector}" gs_width="690" gs_type="goods" gs_store_id="{$visitor.store_id}" ectype="gselector" gs_uri="{url route='gselector/goods'}" class="btn-add-product">{$lang.gselector}</a> <span class="block mt10" id="goods_name"></span>
                        <input type="hidden" id="seller_limitbuy" name="goods_id" value="{$limitbuy.goods_id}" />
                      </p>
                    </div>
                    <div class="assort clearfix">
                      <p class="txt float-left">{$lang.spec_price}: </p>
                      <div ectype="spec_list" class="spec float-left">
                        <ul class="th">
                          <li id="spec_name" class="distance2">{$lang.spec}</li>
                          <li class="distance1">{$lang.stock}</li>
                          <li class="distance1">{$lang.price}</li>
                          <li class="distance2" style="width:130px;">{$lang.pro_price}</li>
                          <li class="distance1">{$lang.pro_type}</li>
                        </ul>
                      </div>
                      <div ectype="template" class="hidden">
                        <ul ectype="spec_item" class="td">
                          <li class="distance2">
                            <input ecname="spec_id[]" value="[1]" type="hidden" />
                            [2]</li>
                          <li class="distance1">[3]</li>
                          <li class="distance1">
                            <input ecname="price[[4]]" type="hidden" value="[5]" />
                            [6]</li>
                          <li class="distance1" style="width:130px;">
                            <input ectype="pro_price" placeholder="0.01-9.99" ecname="pro_price[[7]]" type="text" class="text width2" value="[8]" />
                          </li>
                          <li class="distance1">
                            <select ectype="pro_type" ecname="pro_type[[9]]" >
                              <option value="price" selected="[10]" >{$lang.pro_type_price}</option>
                              <option value="discount" selected="[11]" >{$lang.pro_type_discount}</option>
                            </select>
                          </li>
                        </ul>
                      </div>
                    </div>
                    <div class="assort issuance">
                      <p class="txt"></p>
                      <p>
                        <input type="submit" class="J_AjaxSubmit btn-alipay" style="width:200px;" value="{$lang.submit}" />
                      </p>
                    </div>
                  </div>
                </div>
              </form>
              <!--{/if}--> 
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
$(function(){
    $('#start_time').datetimepicker({
      timeText: '时间',
      hourText: '小时',
      minuteText: '分钟',
      secondText: '秒',
      currentText: '现在',
      closeText: '完成',
      showSecond: true, //显示秒  
      timeFormat: 'HH:mm:ss' //格式化时间
    });
    $('#end_time').datetimepicker({
      timeText: '时间',
      hourText: '小时',
      minuteText: '分钟',
      secondText: '秒',
      currentText: '现在',
      closeText: '完成',
      showSecond: true, //显示秒  
      timeFormat: 'HH:mm:ss' //格式化时间
    });
	
	  gs_query_info1({$limitbuy.goods_id|default:0}, {$limitbuy.pro_id|default:0});
});
function gs_submit_check(id,name,callback)
{
	if(DATA_LIST_TEMP.length != 1) {
		msg(lang.records_error);
	}
	else {
		gs_submit(id,name,callback);
	}
}
function gs_callback1(id)
{
	var goods_id = '';
	$.each(DATA_LIST_TEMP, function(i,item){
		goods_id = item.goods_id;
	});
	if(goods_id.length == 0 || (goods_id == 0)){
		//$('.J_ListAdded').hide();
        msg(lang.add_records);
	}
	else {
		$('#'+id).val($('#gs_goods_id').val());
		gs_query_info1(goods_id);
		DialogManager.close(id);
	}
}
function gs_query_info1(goods_id, toolId)
{
	$.getJSON(url(['seller_limitbuy/query']),{ id:goods_id, toolId: toolId},function(data) {
		if(data.done){
			if(data.retval) {
				var goods = data.retval;

				$('#seller_limitbuy').val(goods_id);
				$('#goods_name').html(goods.goods_name);
				$('#spec_name').html(goods.spec_name);
				$('*[ectype="spec_list"]').find('ul[ectype="spec_item"]').remove();
				
				var html = '';
				var template = $('*[ectype="template"]').clone(true);
				$.each(goods.goodsSpec, function(i,item) {
					html += sprintf(replace_all(template.html(), 'ecname', 'name'), item.spec_id, item.spec, item.stock, item.spec_id, item.price, item.price, item.spec_id, item.pro_price ? item.pro_price : '', item.spec_id, (item.pro_type == 'price') ? 'selected' : '', (item.pro_type != 'price') ? 'selected' : '');
				});
				html = replace_all(html, 'selected=""', '');
				$('*[ectype="spec_list"]').append(html);
			}	
 		}
 	});
}
</script> 
{include file="user.footer.html"} 